home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / miscuni.com / MESSAGES.DOC < prev    next >
Encoding:
Text File  |  1989-05-25  |  5.4 KB  |  185 lines

  1. Messages
  2. --------
  3.  
  4. Messages is a unit which allows programs to display pop up error
  5. messages with a minimum of formatting.  It uses Turbo
  6. Professional 5.0 for windowing and screen display.  The central
  7. routine (Message) takes only 1 parameter which is a string.  The
  8. string may contain imbedded commands which handle many aspects of
  9. how the windows and messages are to display.
  10.  
  11. Constants
  12.  
  13.   CmdPre = #0
  14.  
  15. This is the character that identifies message string commands.
  16. When encountered in a string, the Message routine will expect a
  17. command to follow.
  18.  
  19.   NewLnCmd = #0#1
  20.  
  21. When included in a message string, this command will force the
  22. beginning of a new line.  This must be used in messages that are
  23. longer than the width of the screen.
  24.  
  25.   TitleCmd #0#6
  26.  
  27. This constant is used to block out the portion of the string that
  28. contains the window header and message window descriptors.  This
  29. should appear once at the beginning and at the end of the header
  30. portion of the string.
  31.  
  32.   DelayCmd = #0#12
  33.  
  34. This is the beginning of a three character command and should be
  35. directly followed by a 'parameter byte' which will be interpreted
  36. by the message parser.  When this character sequence is
  37. encountered, the pop up window will remain on screen
  38. approximately n seconds, where n is specified by the parameter
  39. passed with this command (the byte directly following the
  40. command) OR until a key is pressed.
  41.  
  42. The following command sequences are only valid when passed as
  43. part of the header portion of the string (between TitleCmd's):
  44.  
  45.   BeepCmd = #0#7
  46.  
  47. Causes the bell to sound when the window is displayed.
  48.  
  49.   RowCmd = #0#8
  50.  
  51. This is a three byte command it tells the message routine to
  52. position the top of the message window at the row specified by
  53. the parameter byte of this command.  If the row specified is too
  54. low, the window will be moved up to the lowest row possible.
  55.  
  56.   ColCmd = #0#9
  57.  
  58. This is a three byte command it tells the message routine to
  59. position the left side of the message window at the column specified by
  60. the parameter byte of this command.  If the column specified is too
  61. high to fit the entire window, the window will be moved as far as
  62. possible to the left of the screen.
  63.  
  64.   PauseCmd = #0#10
  65.  
  66. This command causes the window to remain on the screen until a
  67. key is pressed.
  68.  
  69.   LeaveCmd = #0#11
  70.  
  71. Causes the message window to remain on screen until a call to the
  72. RemoveMsg procedure.
  73.  
  74.   LeftCmd = #0#3
  75.  
  76. Causes each line of the message string to be left justified
  77. within the message window.
  78.  
  79.   RightCmd = #0#4
  80.  
  81. Causes each line of the message string to be right justified
  82. within the message window.
  83.  
  84.   CenterCmd = #0#5
  85.  
  86. Causes each line of the message string to be centered within the
  87. message window.
  88.  
  89. Types
  90.  
  91.   MsgStr = String
  92.  
  93.   JustifyType = (Left, Right, Cntr)
  94.  
  95.   ReadKeyFunc = Function : Word
  96.  
  97.   LoopProc = Procedure
  98.  
  99. Variables
  100.  
  101.   MsgWinTopRow,
  102.   MsgWinFirstCol : Byte
  103.  
  104. These variables provide the defaults for the positioning of the
  105. message window.  They default to 0 for windows that are centered
  106. on the screen.
  107.  
  108.   MsgWinColor: FlexAttrs
  109.  
  110. The default attributes of the message windows.  Message strings
  111. are written using the FlexWriteWindow routine from TPCRT.  The
  112. window color is set to MsgWinColor[0]
  113.  
  114.   MsgFrameColor,
  115.   MsgTitleColor : byte
  116.  
  117. These are the default colors for the window frames and headers.
  118.  
  119.   MsgWinDefLen : byte
  120.  
  121. This is the default length of the message window.  When set to 0,
  122. windows will be sized automatically.  If set to a non-zero
  123. number, the window will be sized to this value OR the length it
  124. will need to fit the longest line of the message string,
  125. whichever is greater.
  126.  
  127.   MsgJust : JustifyType
  128.  
  129. This is the default justification for messages, it is initially
  130. set to Cntr.
  131.  
  132.   MsgDisposeCh : boolean
  133.  
  134. When set to true, message windows that wait for keypresses will
  135. "eat" the key and return to the calling routine.  It this is set
  136. to false, the key will remain in the keyboard buffer.
  137.  
  138.   MsgReadKeyWord : ReadKeyFunc
  139.  
  140. This is the default function used to read key input.  It defaults
  141. to ReadKeyWord.
  142.  
  143.   MsgLoopProc : LoopProc
  144.  
  145. This is a procedure that takes no parameters and is repeatedly
  146. executed while the message window is waiting for keyboard input.
  147. It defaults to a procedure that does nothing.  Note that tis will
  148. not be executed in messages that contain the LeaveCmd, as these
  149. types of message windows do not wait for any keyboard input.
  150.  
  151. Message Routines
  152.  
  153.   procedure SetMsgDefaults( WindowColor: FlexAttrs; FrameColor, TitleColor,
  154.                             TopRow, TopCol: byte; Just: JustifyType )
  155.  
  156. This routine can be used to set some of the message unti defaults
  157. without accessing the individual variables directly.
  158.  
  159.   type CStr = String[3]
  160.  
  161.   function CmdStr( Cmd: CStr; P:byte ): CStr
  162.  
  163. This function returns a string containing the parameter Cmd
  164. concatenated with char( P ).  It provides a quick way to specify
  165. commands that take a parameter byte.  Example:
  166.  
  167.   RowCmd + Char(5) is the same as
  168.   CmdStr( RowCmd, 5)
  169.  
  170. Note: It is often easier to simply use RowCmd+#5, however using
  171. the CmdStr function (in my opinion) just seems a bit more
  172. intuitive.
  173.  
  174.   procedure Message( S : MsgStr )
  175.  
  176. This is the main routine which displays the message window and
  177. the associated string(s).
  178.  
  179.   procedure RemoveMsg
  180.  
  181. Erases the last message window left on the screen using the
  182. LeaveCmd.
  183.  
  184.  
  185.